package com.blockchain.front.config.data.dev;

import java.util.Properties;

import com.blockchain.framework.data.sql.mysql.AbstractDriverConnectionProvider;
import com.blockchain.framework.log.Logger;
import com.blockchain.framework.resource.InitParameterProvider;
import com.blockchain.framework.resource.ResourceAnnotation;
import com.blockchain.framework.resource.ResourceRetention;
import com.blockchain.variables.P2PConst;

@ResourceAnnotation(ResourceRetention.DEVELOMENT)
public class Master extends AbstractDriverConnectionProvider {

	public Master(InitParameterProvider parameterProvider, Logger logger) {
		super(parameterProvider, logger);
		driver = "com.mysql.jdbc.Driver";
		if(P2PConst.Test) {
			url = "jdbc:mysql://localhost:3306/"+P2PConst.DB_PREFIX+"_s50";
			properties = new Properties();
			properties.setProperty("user", "admin");
			properties.setProperty("password", "123456");
		}
		else {
			url = "jdbc:mysql://rm-j6c5is6u89223mpafo.mysql.rds.aliyuncs.com:3306/"+P2PConst.DB_PREFIX+"_s50";
			properties = new Properties();
			properties.setProperty("user", "faker");
			properties.setProperty("password", "$skt6666");
		}
		
		properties.setProperty("useUnicode", "true");
		properties.setProperty("characterEncoding", "UTF8");
		properties.setProperty("useSSL", "false");
	}

	@Override
	public String getName() {
		return P2PConst.DB_MASTER_PROVIDER;
	}

}
